import javax.swing.*;

public class ComputeLoan {
    public static void main(String[] args) {
        String interese = JOptionPane.showInputDialog(null, "Ievadi ikgadējo gada likmi (%) :", "Gada likme", JOptionPane.QUESTION_MESSAGE);
        double annualInterestRate = Double.parseDouble(interese);
        
        double monthlyInterestRate = annualInterestRate / 1200;
        
        String gadi = JOptionPane.showInputDialog(null, "Ievadi gadu skaitu :", "Gadi", JOptionPane.QUESTION_MESSAGE);
        int numberOfYears = Integer.parseInt(gadi);
        
        String kredits = JOptionPane.showInputDialog(null, "Ievadi līzinga summu :", "Līzings", JOptionPane.QUESTION_MESSAGE);
        double loanAmount = Double.parseDouble(kredits);
        
        double monthlyPayment = loanAmount * monthlyInterestRate / (1 - 1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12));
        double totalPayment = monthlyPayment * numberOfYears * 12;
        
        JOptionPane.showMessageDialog(null, "Ikmēneša maksājums sastāda " + (int)(monthlyPayment * 100) / 100.0);
        JOptionPane.showMessageDialog(null, "Kopējais maksājums sastāda " + (int)(totalPayment * 100) / 100.0);
    }
}